package com.csun.cmny.provider.service.impl;

import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.OmcOrderServiceItemContentMapper;
import com.csun.cmny.provider.model.domain.OmcOrderServiceItemContent;
import com.csun.cmny.provider.service.OmcOrderServiceItemContentService;
import com.csun.cmny.provider.vo.OrderServiceItemContentVo;
import com.csun.cmny.provider.vo.OrderServiceItemVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
@Transactional
public class OmcOrderServiceItemContentServiceImpl extends BaseService<OmcOrderServiceItemContent> implements OmcOrderServiceItemContentService {

    @Resource
    OmcOrderServiceItemContentMapper omcOrderServiceItemContentMapper;

    @Override
    public List<OrderServiceItemContentVo> selectByOrderServiceItemId(Long orderServiceItemId) {
        return omcOrderServiceItemContentMapper.selectByOrderServiceItemId(orderServiceItemId);
    }

    @Override
    public List<OrderServiceItemVo> setContents(List<OrderServiceItemVo> orderServiceItemVos) {
        if(orderServiceItemVos.size() > 0){
            for(OrderServiceItemVo vo : orderServiceItemVos){
                List<OrderServiceItemContentVo> contents = omcOrderServiceItemContentMapper.selectByOrderServiceItemId(vo.getId());
                if(contents.size() > 0){
                    vo.setOrderServiceItemContentVos(contents);
                }
            }
        }
        return orderServiceItemVos;
    }
}
